[slug].vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <script lang='ts' setup>
  2. import { Api } from '@/api/model/url'
  3. import { useCommonStore } from '@/stores/modules/common'
  4. const route = useRoute()
  5. const detail = ref<any>({})
  6. const tabValue = ref('blog')
  7. const isHasCatalogue = ref(true)
  8. const options = ref([
  9. {
  10. label: 'Read Blog',
  11. value: 'blog',
  12. },
  13. {
  14. label: 'Preview Catalog',
  15. value: 'catalog',
  16. },
  17. ])
  18. const slug = route.params.slug
  19. const { data, pending, error, refresh } = await useAsyncData(
  20. 'blog-detail',
  21. () =>
  22. $fetch(`${process.env.MY_ENV_DEV_URL}${Api.BlogDetail}`, { params: { slug } }),
  23. )
  24. const seoData = data.value?.result
  25. // 把createTime和updateTime转换为ISO格式
  26. if (seoData?.createTime)
  27. seoData.createTime = new Date(seoData.createTime).toISOString()
  28. if (seoData?.updateTime)
  29. seoData.updateTime = new Date(seoData.updateTime).toISOString()
  30. if (!seoData?.relatedCatalogue)
  31. isHasCatalogue.value = false
  32. detail.value = seoData
  33. useHead({
  34. title: detail.value?.metaTitle,
  35. meta: [
  36. {
  37. name: 'description',
  38. content: detail.value?.metaDescribe,
  39. },
  40. {
  41. property: 'og:title',
  42. content: detail.value?.metaTitle,
  43. },
  44. {
  45. property: 'og:description',
  46. content: detail.value?.metaDescribe,
  47. },
  48. {
  49. property: 'og:image',
  50. content: detail.value?.thumbnailUrl,
  51. },
  52. {
  53. property: 'og:url',
  54. content: `${process.env.MY_ENV_DEV_URL}/blog/${slug}`,
  55. },
  56. {
  57. property: 'og:type',
  58. content: 'website',
  59. },
  60. {
  61. property: 'twitter:title',
  62. content: detail.value?.metaTitle,
  63. },
  64. {
  65. property: 'twitter:description',
  66. content: detail.value?.metaDescribe,
  67. },
  68. {
  69. property: 'twitter:site',
  70. content: `${process.env.MY_ENV_DEV_URL}/blog/${slug}`,
  71. },
  72. {
  73. property: 'twitter:image',
  74. content: detail.value?.thumbnailUrl,
  75. },
  76. {
  77. property: 'twitter:card',
  78. content: 'summary_large_image',
  79. },
  80. ],
  81. script: [
  82. // JSON-LD
  83. {
  84. type: 'application/ld+json',
  85. children: JSON.stringify({
  86. datePublished: detail.value?.createTime,
  87. dateModified: detail.value?.updateTime,
  88. }),
  89. },
  90. ],
  91. link: [
  92. {
  93. rel: 'canonical',
  94. href: `${process.env.MY_ENV_DEV_URL}/blog/${slug}`,
  95. },
  96. ],
  97. })
  98. const { openLoginAndDownloadModal } = useLoginAndDownLoadModal()
  99. async function clickLoginAndDownload(item: any) {
  100. try {
  101. const commonStore = useCommonStore()
  102. commonStore.setDownloadCatalog(item)
  103. const { status } = await openLoginAndDownloadModal()
  104. if (status)
  105. location.reload()
  106. }
  107. catch (error) {
  108. console.log(error)
  109. }
  110. }
  111. </script>
  112. <template>
  113. <div class="blog-detail">
  114. <div class="bg-#F3F4FB ">
  115. <div class="pt-175px pb-110px w-1200-auto flex px-60px">
  116. <img :src="detail?.thumbnailUrl" :alt="detail?.thumbnailAlt" srcset="" class="w-410px h-256px b-rd-10px object-cover mr-40px">
  117. <div class="flex-1 text-left">
  118. <div class="b-rd-400px left-10px text-center w-138px h-32px lh-32px bg-#fff/50 backdrop-blur-20px b-1px b-solid b-#fff/60 text-#9B6CFF text-14px mb-20px">
  119. {{ detail.category_dictText }}
  120. </div>
  121. <h1
  122. class="!mb-20px fw-800 text-40px ls-2 text-#333 line-clamp-2 lh-50px custom-title-font"
  123. >
  124. {{ detail.contentTitle }}
  125. </h1>
  126. <div class="text-16px text-#999 lh-24px">
  127. {{ detail.contentSubhead }}
  128. </div>
  129. </div>
  130. </div>
  131. </div>
  132. <div class="w-1200-auto flex pt-30px">
  133. <div class="w-840px mr-60px">
  134. <div v-if="isHasCatalogue">
  135. <el-segmented v-model="tabValue" :options="options">
  136. <template #default="scope">
  137. <div>
  138. <div>{{ scope.item.label }}</div>
  139. </div>
  140. </template>
  141. </el-segmented>
  142. </div>
  143. <div v-show="tabValue === 'blog'" class="mt-30px content-detail custom-html" v-html="detail.content" />
  144. <div v-show="tabValue === 'catalog'" class="mt-30px">
  145. <iframe
  146. :src="`${detail?.relatedCatalogue?.viewPdf}#view=FitH&toolbar=0&scrollbar=0&navpanes=0`"
  147. allowfullscreen
  148. width="100%"
  149. height="1200px"
  150. style="border: none"
  151. >
  152. 您的浏览器不支持iframe,请使用现代浏览器查看PDF。
  153. </iframe>
  154. </div>
  155. </div>
  156. <div class="flex-1">
  157. <div v-if="isHasCatalogue" class="pos-relative mb-40px">
  158. <img :src="detail?.relatedCatalogue?.coverImg" :alt="detail?.relatedCatalogue?.coverAlt" srcset="" class="w-375px h-240px b-rd-10px object-cover">
  159. <h4
  160. class="!mb-15px !mt-30px fw-800 text-24px text-#333 line-clamp-2"
  161. >
  162. {{ detail?.relatedCatalogue?.title }}
  163. </h4>
  164. <div class="text-14px text-#999 lh-22px line-clamp-2 mb-20px">
  165. {{ detail?.relatedCatalogue?.subhead }}
  166. </div>
  167. <el-button class="!bg-#9B6CFF !text-#fff !b-#9B6CFF !b-rd-380px text-14px fw-bold !h-32px px-20px" @click="clickLoginAndDownload(detail?.relatedCatalogue)">
  168. Download Catalog
  169. </el-button>
  170. </div>
  171. <div class="px-40px pt-34px bg-#E7EAFF b-rd-10px text-center custom-main">
  172. <div class="text-#333 fw-500">
  173. Contact Us to Get
  174. </div>
  175. <div class="text-#333 fw-500 my-6px">
  176. Exclusive Trending Products
  177. </div>
  178. <div class="text-#333 fw-500">
  179. Solutions
  180. </div>
  181. <el-button class="mt-20px !bg-#fff !text-#9B6CFF !w-160px !h-40px !b-0px !b-rd-200px" round>
  182. <nuxt-link :to="{ name: 'contact' }">
  183. Contact Us
  184. </nuxt-link>
  185. </el-button>
  186. </div>
  187. </div>
  188. </div>
  189. <common-block-blog class="!pb-0" />
  190. <AppFooter />
  191. </div>
  192. </template>
  193. <style lang='less' scoped>
  194. .el-segmented {
  195. --el-segmented-item-selected-color: #fff;
  196. --el-segmented-item-selected-bg-color: #9B6CFF;
  197. --el-border-radius-base: 16px;
  198. --el-segmented-bg-color: #F9FAFB;
  199. --el-segmented-color: #333;
  200. width: 100%;
  201. height: 68px;
  202. line-height: 68px;
  203. border-radius: 300px!important;
  204. overflow: hidden;
  205. padding: 0;
  206. ::v-deep .el-segmented__group {
  207. .el-segmented__item-selected,.el-segmented__item{
  208. border-radius: 300px!important;
  209. overflow: hidden;
  210. .el-segmented__item-label{
  211. font-size: 18px;
  212. }
  213. }
  214. }
  215. }
  216. .blog-detail {
  217. ::v-deep(.content-detail) {
  218. font-family: sans-serif;
  219. h2 {
  220. font-size: 1.5em;
  221. font-family: "CustomTitleFont";
  222. margin-top: 1em !important;
  223. margin-bottom: 1em !important;
  224. font-weight: bold;
  225. }
  226. h3 {
  227. display: block;
  228. font-size: 1.17em;
  229. margin-block-start: 1em;
  230. margin-block-end: 1em;
  231. margin-inline-start: 0px;
  232. margin-inline-end: 0px;
  233. margin-bottom: 1em !important;
  234. font-weight: bold;
  235. unicode-bidi: isolate;
  236. font-family: "CustomTitleFont";
  237. }
  238. p {
  239. display: block;
  240. margin-block-start: 1em;
  241. margin-block-end: 1em;
  242. margin-inline-start: 0px;
  243. margin-inline-end: 0px;
  244. unicode-bidi: isolate;
  245. }
  246. ul {
  247. display: block;
  248. list-style-type: disc;
  249. margin-block-start: 1em;
  250. margin-block-end: 1em;
  251. margin-inline-start: 0px;
  252. margin-inline-end: 0px;
  253. padding-inline-start: 40px;
  254. unicode-bidi: isolate;
  255. li {
  256. display: list-item;
  257. text-align: -webkit-match-parent;
  258. unicode-bidi: isolate;
  259. }
  260. }
  261. ol {
  262. list-style-type: decimal;
  263. display: block;
  264. list-style-type: decimal;
  265. margin-block-start: 1em;
  266. margin-block-end: 1em;
  267. margin-inline-start: 0px;
  268. margin-inline-end: 0px;
  269. padding-inline-start: 40px;
  270. unicode-bidi: isolate;
  271. }
  272. }
  273. }
  274. .custom-main{
  275. background: url('~/assets/images/swiper_bg.png') no-repeat center center;
  276. background-size: cover;
  277. width: 300px;
  278. height: 190px;
  279. }
  280. </style>